﻿using Data.Video;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Index2.Controllers
{
    public class HomeController : Controller
    {

        private VideoEntities db = new VideoEntities();
        public ActionResult ChiTietTin(string id)
        {
            var obj = db.Video.Where(e => e.YCode.Contains(id)).FirstOrDefault();
            Video v = new Video();
            if (obj != null) {
                v = obj;
              ViewBag.Cate = db.Category.Where(e => e.ID == obj.CateId).FirstOrDefault();
            }
            return PartialView(v);
        } 
        public ActionResult Index( int? id)
        {            
            var lsttop = db.Video.Take(20).ToList();
            return View(lsttop);
        }
        public PartialViewResult Sidebar()
        {
            var lsttop = db.Video.Take(20).ToList(); 
            return PartialView(lsttop);
        }
    }
}
